package com.xcw.bos.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Repository;

import com.xcw.bos.dao.IFunctionDao;
import com.xcw.bos.dao.base.impl.BaseDaoImpl;
import com.xcw.bos.domain.Function;
import com.xcw.bos.page.PageBean;
@Repository
public class FunctionDaoImpl extends BaseDaoImpl<Function> implements
		IFunctionDao {

	public List<Function> findFunctionListByUserId(String userid) {
		String hql = "FROM Function f left outer join fetch f.roles r.users u where u.id = ? ";
		List<Function> list = this.getHibernateTemplate().find(hql, userid);
		return list;
	}

	public List<Function> findAllMenu() {
		String hql = "from Function where generatemenu = '1' order by zindex desc";
		
		return this.getHibernateTemplate().find(hql);
	}

	public List<Function> findMenu(String userid) {
		String hql = "select DISTINCT f FROM  Function f left outer join fetch f.roles r left outer join fetch r.users u where u.id = ? and f.generatemenu = '1' order by f.zindex desc";
		return this.getHibernateTemplate().find(hql, userid);
	}

}
